﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Irvin_Engine;

namespace Irvin_Engine.State
{
    public enum ActiveState
    {
        NONE,
        TRANSITION_ON,
        TRANSITION_OFF,
        ACTIVE
    }

    public enum TypeState
    {
        GAMESTATE,
        POPUP
    }

    public abstract class GameState
    {
        /// <summary>
        /// Détermine l'activité du state
        /// </summary>
        protected bool isActive = false;
        public bool IsActive
        {
            set { isActive = value; }
            get { return (currentActiveState == ActiveState.ACTIVE || currentActiveState == ActiveState.TRANSITION_ON || currentActiveState == ActiveState.TRANSITION_OFF); }
        }

        protected bool isPopup = false;
        public bool IsPopup
        {
            get
            {
                return isPopup;
            }
        }

        protected TypeState typeState = TypeState.GAMESTATE;
        public TypeState TypeState
        {
            get
            {
                return typeState;
            }
        }

        /// <summary>
        /// Temps de transition
        /// </summary>
        protected int TimeTransitionOn = 0;
        protected int TimeTransitionOff = 0;

        ActiveState currentActiveState = ActiveState.NONE;

        /// <summary>
        /// Texture de fond et sa position
        /// </summary>
        private Texture2D picBackground = null;
        private Rectangle placementBackground;

        public GameState()
        {
            placementBackground = new Rectangle(0, 0, 0, 0);
        }

        public GameState(string _nameBackground, TypeState _typeState)
        {
            if (_nameBackground != null)
            {
                picBackground = Kernel.GetInstance().Content.Load<Texture2D>(_nameBackground);
                placementBackground = new Rectangle(0, 0, picBackground.Width, picBackground.Height);
            }
            typeState = _typeState;
        }

        abstract public string GetID();

        virtual public void Update(GameTime _gameTime)
        {
        }

        virtual public void Draw(GameTime _gameTime)
        {
            Kernel.GetInstance().SpriteBatch.Draw(picBackground, placementBackground, Color.White);
        }
    }
}
